#!/bin/bash
set -e

# Update the /etc/clearwater/config file, the node.json, and re-run
# chef-solo
$CHARM_DIR/lib/config_script
$CHARM_DIR/lib/node_json_script
chef-solo -c /home/ubuntu/chef-solo/solo.rb -j /home/ubuntu/chef-solo/node.json
$CHARM_DIR/lib/restart

# Create subscribers
if [ "$(config-get base_number)" != "" ] ; then
  /usr/share/clearwater/ellis/env/bin/python /usr/share/clearwater/ellis/src/metaswitch/ellis/tools/create_numbers.py --start "$(config-get base_number)" --count "$(config-get number_count)"
fi
